window.onload = function () {
	downList();
	changeTop();
	loginChange();
};
// 菜单 的显示和隐藏
function downList() {
	let down = document.querySelector(".down");
	let list = document.querySelector(".list")
	let flag = true;
	
	down.addEventListener("click", function () {
		if (flag) {	
			list.style.display = "block";
			flag = false;
		} else {
			list.style.display = "none";
			flag = true;
	}
	})
}

// window 卷去的高度为header——top和header——search时显示向上箭头
function changeTop() {
	let top = document.querySelector(".aside .top");
	let headerTop = document.querySelector(".header_top");
	let headerSearch = document.querySelector(".header_search");
	const headerTopHeight = headerTop.offsetHeight;
	const headerSearchHeight = headerSearch.offsetHeight;
	const allHeight=headerSearchHeight+headerTopHeight;
	window.onscroll = function (e) {
	if (this.pageYOffset<allHeight) {
		top.style.display = "none";
	} else {
		top.style.display = "block";
		top.addEventListener("click", function (event) {
			document.documentElement.scrollTop = 0;//获取根元素卷曲的距离赋值为0
		})		
		}
	}
}

// 点击登陆显示遮罩层和login
function loginChange() {
	let register = document.querySelector(".register");
	let loginBox = document.querySelector(".loginBox");
	let Mask = document.querySelector('.Mask');
	let close = loginBox.querySelector(".login_close");
	// console.log(close);
	register.addEventListener("click", function () {
		loginBox.style.display = "block";
		Mask.style.display = "block";
		closeLogin();
	})
	function closeLogin() {
		close.addEventListener("click", function () {
			loginBox.style.display = "none";
			Mask.style.display = "none";

		})
	}


}


